<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="../../include/admincontent.jsp" %>
<style>
    #searchbox table thead td {
        border-bottom: none;
    }
</style>
<div id="Content">
    <form id="modelform" method="post" action="/Do/BS/EditRoomAction">
        <input type="hidden" name="id" value="${room.id}"/>
        <div class="toolbars">
            <a id="save">
                <em class="ico16 save_traft_16"></em>
                <span class="menu_span" title="保存">保存</span>
            </a>
        </div>
        <table class="treeTable inputform" style="margin-top: 10px">
            <tbody>
            <tr>
                <td width="90">考场名称:</td>
                <td width="400" style="border-right:none;">
                    <div><input type="text" name="name" value="${room.name}" datatype="*" nullmsg="考场名称不能为空"/></div>
                </td>
                <td></td>
            </tr>
            <tr>
                <td>考场别名:</td>
                <td style="border-right:none;">
                    <div><input type="text" name="nickname" value="${room.nickname}" datatype="*" nullmsg="考场别名不能为空"/>
                    </div>
                </td>
                <td>准考证上的考场名称</td>
            </tr>
            <tr>
                <td>考场地址:</td>
                <td style="border-right:none;">
                    <div><input type="text" name="address" value="${room.address}" datatype="*" nullmsg="考场地址不能为空"/>
                    </div>
                </td>
                <td>准考证上的考试地址</td>
            </tr>
            <tr>
                <td>座位开始编号:</td>
                <td style="border-right:none;">
                    <div><input type="text" name="startnum" value="${room.startnum}" datatype="zzzs"
                                nullmsg="座位开始编号不能为空"/></div>
                </td>
                <td></td>
            </tr>
            <tr>
                <td>有效座位数量:</td>
                <td style="border-right:none;">
                    <div><input type="text" name="allcount" value="${room.allcount}" datatype="zzzs"
                                nullmsg="有效座位数量不能为空"/></div>
                </td>
                <td></td>
            </tr>
            <tr>
                <td>状态:</td>
                <td style="border-right:none;">
                    <div><select name="state">
                        <option value="启用">启用</option>
                        <option value="禁用">禁用</option>
                    </select><input type="hidden" value="${room.state}"/></div>
                </td>
                <td></td>
            </tr>
            <tr>
                <td>优先级:</td>
                <td style="border-right:none;">
                    <div><input type="text" name="priority" value="${room.priority}" datatype="zzzs"
                                nullmsg="优先级不能为空"/></div>
                </td>
                <td></td>
            </tr>
            </tbody>
        </table>
    </form>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $('select').each(function () {
            $(this).val($(this).next().val());
        });

        $('#save').click(function () {
            var data = {};
            data["id"] = $("input[name = 'id']").val();
            data["name"] = $("input[name = 'name']").val();
            if (data["name"] == ""){
                layer.msg("考场名称不能为空", {icon: 2});
                return;
            }
            data["nickname"] = $("input[name = 'nickname']").val();
            if (data["nickname"] == ""){
                layer.msg("考场别名不能为空", {icon: 2});
                return;
            }
            data["address"] = $("input[name = 'address']").val();
            if (data["address"] == ""){
                layer.msg("考场地址不能为空", {icon: 2});
                return;
            }
            data["startnum"] = $("input[name = 'startnum']").val();
            if (data["startnum"] == ""){
                layer.msg("座位开始编号不能为空", {icon: 2});
                return;
            }
            data["allcount"] = $("input[name = 'allcount']").val();
            if (data["startnum"] == ""){
                layer.msg("座位开始编号不能为空", {icon: 2});
                return;
            }
            data["state"] = $("select[name = 'state']").val();
            if (data["state"] == ""){
                layer.msg("有效座位数量不能为空", {icon: 2});
                return;
            }
            data["priority"] = $("input[name = 'priority']").val();
            if (data["priority"] == ""){
                layer.msg("优先级不能为空", {icon: 2});
                return;
            }
            $.ajax({
                url: "/Do/BS/EditRoomAction",
                type: 'POST',
                data: data,
                success: function (data) {
                    if (data.state){
                        layer.msg(data.Message, {icon: 1});
                        parent.location.reload();
                    }else {
                        layer.msg(data.Message, {icon: 2});
                    }

                },
                error: function (data) {
                    layer.msg(data.Message, {icon: 2});
                }
            });
        });
    });
</script>
</body>
</html>